package com.malred;

import com.mybatisPlusSpring.myImportBeanDefinitionRegister;
import com.mybatisPlusSpring.myScan;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.io.Resource;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author malguy-wang sir
 * @create ---
 */
@ComponentScan("com.malred")
@myScan("com.malred.mappers")
public class config {
    @Bean
    public SqlSessionFactory sqlSessionFactory(){
        InputStream is = null;
        try {
            is = Resources.getResourceAsStream("mybatis.xml");
        } catch (IOException e) {
            e.printStackTrace();
        }
        SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(is);
        return factory;
    }
}
